package com.timeriver.web;

import com.timeriver.domain.ResponseObj;
import com.timeriver.domain.vo.MenusVO;
import com.timeriver.service.AuthService;
import com.timeriver.utils.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/auth")
public class AuthController {

    @Autowired
    private AuthService service;

    @GetMapping("/menus")
    public ResponseObj getMenus() {
        List<MenusVO> menus = null;
        try {
            menus = service.getMenus();
        } catch (Exception e) {
            e.printStackTrace();
            return ResponseUtil.error(e.getMessage());
        }
        return ResponseUtil.success("菜单列表", menus);
    }
}
